package kr.co.choongang;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


@WebServlet("/EmpSelect")
public class EmpSelectServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	
	public EmpSelectServlet() throws ClassNotFoundException {
		
	}


	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request,response);
	}
	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("text/html;charset=euc-kr");
		PrintWriter out = response.getWriter();
		out.print("<html><body>");
		EmpSelectDTO empSelectDTO=null;
				try {
					EmpSelectDAO empSelectDAO = new EmpSelectDAO();
					empSelectDAO.setConnection();
					empSelectDAO.setStatement(null);
					ResultSet rs = empSelectDAO.executeQuerySelect();
					while(rs.next()){
						empSelectDTO=empSelectDAO.setSelectResult();
						out.print(empSelectDTO.getEmp_id()+"\t"+empSelectDTO.getEname()+"\t"+empSelectDTO.getSalary()+"\t"+empSelectDTO.getDepart()+"<br>");
					}
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				} catch(Exception e){
					e.printStackTrace();
				}
		
				
				/*	if(rs!=null) rs.close();
					if(conn!=null) conn.close();*/
					
			
		
		
		//out.print("</body></html>");
	}

}
